package org.ting.j20250110_websocket.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.ting.j20250110_websocket.handler.MyWebSocketHandler;
@Configuration
@EnableWebSocket //表示该类为websocket配置类
public class WebSocketConfig implements WebSocketConfigurer {
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        //调用addHandler()方法完成注册，/test 表示url路径
        registry.addHandler(new MyWebSocketHandler(), "/test");
    }
}
